<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: Citygate::User
  
    &mdash; Documentation by YARD 0.8.2.1
  
</title>

  <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />

  <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  hasFrames = window.top.frames.main ? true : false;
  relpath = '../';
  framesUrl = "../frames.html#!" + escape(window.location.href);
</script>


  <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>


  </head>
  <body>
    <div id="header">
      <div id="menu">
  
    <a href="../_index.html">Index (U)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../Citygate.html" title="Citygate (module)">Citygate</a></span></span>
     &raquo; 
    <span class="title">User</span>
  

  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a class="full_list_link" id="class_list_link"
        href="../class_list.html">
      Class List
    </a>
  
    <a class="full_list_link" id="method_list_link"
        href="../method_list.html">
      Method List
    </a>
  
    <a class="full_list_link" id="file_list_link"
        href="../file_list.html">
      File List
    </a>
  
</div>
      <div class="clear"></div>
    </div>

    <iframe id="search_frame"></iframe>

    <div id="content"><h1>Class: Citygate::User
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">ActiveRecord::Base</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">ActiveRecord::Base</li>
          
            <li class="next">Citygate::User</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
      <dt class="r2">Includes:</dt>
      <dd class="r2"><span class='object_link'><a href="../Gravatar.html" title="Gravatar (module)">Gravatar</a></span></dd>
      
    
  
  
  
    <dt class="r1 last">Defined in:</dt>
    <dd class="r1 last">app/models/citygate/user.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  
<p class="tag_title">Author:</p>
<ul class="author">
  
    <li>
      
      
      
      
        
        <div class='inline'><p>
Zamith
</p>
</div>
      
    </li>
  
</ul>

</div>



  <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#email-instance_method" title="#email (instance method)">- (String) <strong>email</strong> </a>
    

    
  </span>
  
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
The email of the user.
</p>
</div></span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#name-instance_method" title="#name (instance method)">- (String) <strong>name</strong> </a>
    

    
  </span>
  
  
  
    
    
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
The name of the user.
</p>
</div></span>
  
</li>

    
  </ul>




  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#as_json-instance_method" title="#as_json (instance method)">- (Hash) <strong>as_json</strong>(options = {}) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Get the json object for an user.
</p>
</div></span>
  
</li>

      
        <li class="protected ">
  <span class="summary_signature">
    
      <a href="#check_no_of_users-instance_method" title="#check_no_of_users (instance method)">- (Object) <strong>check_no_of_users</strong> </a>
    

    
  </span>
  
  
  
  <span class="note title protected">protected</span>
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#full_name-instance_method" title="#full_name (instance method)">- (String) <strong>full_name</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Get the user&#8217;s full name (the concatenation of his first and last
names).
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#name_or_email-instance_method" title="#name_or_email (instance method)">- (String) <strong>name_or_email</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Get the name if it is present or else get the email.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#to_s-instance_method" title="#to_s (instance method)">- (Object) <strong>to_s</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Alias for name_or_email.
</p>
</div></span>
  
</li>

      
    </ul>
  


  
  
  
  
  
  
  
  
  <h3 class="inherited">Methods included from <span class='object_link'><a href="../Gravatar.html" title="Gravatar (module)">Gravatar</a></span></h3>
  <p class="inherited"><span class='object_link'><a href="../Gravatar.html#gravatar_id-instance_method" title="Gravatar#gravatar_id (method)">#gravatar_id</a></span>, <span class='object_link'><a href="../Gravatar.html#gravatar_url-instance_method" title="Gravatar#gravatar_url (method)">#gravatar_url</a></span></p>

  
  <div id="instance_attr_details" class="attr_details">
    <h2>Instance Attribute Details</h2>
    
      
      <span id="email=-instance_method"></span>
      <div class="method_details first">
  <h3 class="signature first" id="email-instance_method">
  
    - (<tt>String</tt>) <strong>email</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>
The email of the user
</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
the email of the user
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/citygate/user.rb', line 8</span>

<span class='kw'>class</span> <span class='const'>User</span> <span class='op'>&lt;</span> <span class='const'>ActiveRecord</span><span class='op'>::</span><span class='const'>Base</span>
  <span class='id identifier rubyid_include'>include</span> <span class='const'>Gravatar</span>

  <span class='comment'># @!group Devise configurations
</span>  <span class='id identifier rubyid_devise'>devise</span> <span class='symbol'>:database_authenticatable</span><span class='comma'>,</span> <span class='symbol'>:registerable</span><span class='comma'>,</span> <span class='symbol'>:encryptable</span><span class='comma'>,</span>
    <span class='symbol'>:recoverable</span><span class='comma'>,</span> <span class='symbol'>:rememberable</span><span class='comma'>,</span> <span class='symbol'>:trackable</span><span class='comma'>,</span> <span class='symbol'>:validatable</span><span class='comma'>,</span> <span class='symbol'>:confirmable</span><span class='comma'>,</span> <span class='symbol'>:omniauthable</span>

  <span class='id identifier rubyid_devise'>devise</span>  <span class='symbol'>:encryptor</span> <span class='op'>=&gt;</span> <span class='symbol'>:sha1</span>
  <span class='comment'># @!endgroup
</span>
  <span class='id identifier rubyid_attr_accessible'>attr_accessible</span> <span class='symbol'>:first_name</span><span class='comma'>,</span> <span class='symbol'>:last_name</span><span class='comma'>,</span> <span class='symbol'>:email</span><span class='comma'>,</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='symbol'>:password_confirmation</span><span class='comma'>,</span> <span class='symbol'>:remember_me</span><span class='comma'>,</span> <span class='symbol'>:confirmed_at</span><span class='comma'>,</span> <span class='symbol'>:role_id</span>

  <span class='id identifier rubyid_has_many'>has_many</span> <span class='symbol'>:authorizations</span><span class='comma'>,</span> <span class='symbol'>:dependent</span> <span class='op'>=&gt;</span> <span class='symbol'>:destroy</span>
  <span class='id identifier rubyid_belongs_to'>belongs_to</span> <span class='symbol'>:role</span>
  
  <span class='id identifier rubyid_before_create'>before_create</span> <span class='symbol'>:check_no_of_users</span>

  <span class='comment'># Get the json object for an user. Used by to_json.
</span>  <span class='comment'># @example
</span>  <span class='comment'>#   {
</span>  <span class='comment'>#     &quot;email&quot;: &quot;user@example.com&quot;,
</span>  <span class='comment'>#     &quot;name&quot;: &quot;First User&quot;,
</span>  <span class='comment'>#     &quot;link&quot;: null,
</span>  <span class='comment'>#     &quot;image&quot;: &quot;https://secure.gravatar.com/avatar/b58996c504c5638798eb6b511e6f49af.png/rating=g&quot;
</span>  <span class='comment'>#   }
</span>  <span class='comment'># @return [Hash] the json object in the form of an hash
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_authorization'>authorization</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_authorizations'>authorizations</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
    <span class='lbrace'>{</span>
      <span class='label'>email:</span> <span class='id identifier rubyid_email'>email</span><span class='comma'>,</span>
      <span class='label'>name:</span> <span class='id identifier rubyid_first_name'>first_name</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_authorization'>authorization</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='kw'>if</span> <span class='id identifier rubyid_authorization'>authorization</span><span class='rparen'>)</span><span class='comma'>,</span>
      <span class='label'>link:</span> <span class='lparen'>(</span><span class='id identifier rubyid_authorization'>authorization</span><span class='period'>.</span><span class='id identifier rubyid_link'>link</span> <span class='kw'>if</span> <span class='id identifier rubyid_authorization'>authorization</span><span class='rparen'>)</span><span class='comma'>,</span>
      <span class='label'>image:</span> <span class='lparen'>(</span><span class='id identifier rubyid_authorization'>authorization</span><span class='period'>.</span><span class='id identifier rubyid_image_url'>image_url</span> <span class='kw'>if</span> <span class='id identifier rubyid_authorization'>authorization</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_gravatar_url'>gravatar_url</span>
    <span class='rbrace'>}</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the name if it is present or else get the email
</span>  <span class='comment'># @return [String] the name or email of the user
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_name_or_email'>name_or_email</span>
     <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_full_name'>full_name</span> <span class='op'>||</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_email'>email</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the user's full name (the concatenation of his first and last names)
</span>  <span class='comment'># @return [String] the user's full name
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_full_name'>full_name</span>
    <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_first_name'>first_name</span><span class='rbrace'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_last_name'>last_name</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span>
    <span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='kw'>nil</span> <span class='op'>:</span> <span class='id identifier rubyid_name'>name</span>
  <span class='kw'>end</span>

  <span class='comment'># Alias for name_or_email
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_name_or_email'>name_or_email</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_protected'>protected</span>

  <span class='kw'>def</span> <span class='id identifier rubyid_check_no_of_users'>check_no_of_users</span>
    <span class='kw'>if</span> <span class='const'>Citygate</span><span class='op'>::</span><span class='const'>Engine</span><span class='period'>.</span><span class='id identifier rubyid_no_of_users'>no_of_users</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>&amp;&amp;</span> <span class='const'>Citygate</span><span class='op'>::</span><span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>&gt;=</span> <span class='const'>Citygate</span><span class='op'>::</span><span class='const'>Engine</span><span class='period'>.</span><span class='id identifier rubyid_no_of_users'>no_of_users</span>
      <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='symbol'>:base</span><span class='comma'>,</span><span class='const'>I18n</span><span class='op'>::</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>users.errors.too_many</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
      <span class='kw'>return</span> <span class='kw'>false</span>
    <span class='kw'>else</span>
      <span class='kw'>return</span> <span class='kw'>true</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id="name=-instance_method"></span>
      <div class="method_details ">
  <h3 class="signature " id="name-instance_method">
  
    - (<tt>String</tt>) <strong>name</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>
The name of the user
</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
the name of the user
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/citygate/user.rb', line 8</span>

<span class='kw'>class</span> <span class='const'>User</span> <span class='op'>&lt;</span> <span class='const'>ActiveRecord</span><span class='op'>::</span><span class='const'>Base</span>
  <span class='id identifier rubyid_include'>include</span> <span class='const'>Gravatar</span>

  <span class='comment'># @!group Devise configurations
</span>  <span class='id identifier rubyid_devise'>devise</span> <span class='symbol'>:database_authenticatable</span><span class='comma'>,</span> <span class='symbol'>:registerable</span><span class='comma'>,</span> <span class='symbol'>:encryptable</span><span class='comma'>,</span>
    <span class='symbol'>:recoverable</span><span class='comma'>,</span> <span class='symbol'>:rememberable</span><span class='comma'>,</span> <span class='symbol'>:trackable</span><span class='comma'>,</span> <span class='symbol'>:validatable</span><span class='comma'>,</span> <span class='symbol'>:confirmable</span><span class='comma'>,</span> <span class='symbol'>:omniauthable</span>

  <span class='id identifier rubyid_devise'>devise</span>  <span class='symbol'>:encryptor</span> <span class='op'>=&gt;</span> <span class='symbol'>:sha1</span>
  <span class='comment'># @!endgroup
</span>
  <span class='id identifier rubyid_attr_accessible'>attr_accessible</span> <span class='symbol'>:first_name</span><span class='comma'>,</span> <span class='symbol'>:last_name</span><span class='comma'>,</span> <span class='symbol'>:email</span><span class='comma'>,</span> <span class='symbol'>:password</span><span class='comma'>,</span> <span class='symbol'>:password_confirmation</span><span class='comma'>,</span> <span class='symbol'>:remember_me</span><span class='comma'>,</span> <span class='symbol'>:confirmed_at</span><span class='comma'>,</span> <span class='symbol'>:role_id</span>

  <span class='id identifier rubyid_has_many'>has_many</span> <span class='symbol'>:authorizations</span><span class='comma'>,</span> <span class='symbol'>:dependent</span> <span class='op'>=&gt;</span> <span class='symbol'>:destroy</span>
  <span class='id identifier rubyid_belongs_to'>belongs_to</span> <span class='symbol'>:role</span>
  
  <span class='id identifier rubyid_before_create'>before_create</span> <span class='symbol'>:check_no_of_users</span>

  <span class='comment'># Get the json object for an user. Used by to_json.
</span>  <span class='comment'># @example
</span>  <span class='comment'>#   {
</span>  <span class='comment'>#     &quot;email&quot;: &quot;user@example.com&quot;,
</span>  <span class='comment'>#     &quot;name&quot;: &quot;First User&quot;,
</span>  <span class='comment'>#     &quot;link&quot;: null,
</span>  <span class='comment'>#     &quot;image&quot;: &quot;https://secure.gravatar.com/avatar/b58996c504c5638798eb6b511e6f49af.png/rating=g&quot;
</span>  <span class='comment'>#   }
</span>  <span class='comment'># @return [Hash] the json object in the form of an hash
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_authorization'>authorization</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_authorizations'>authorizations</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
    <span class='lbrace'>{</span>
      <span class='label'>email:</span> <span class='id identifier rubyid_email'>email</span><span class='comma'>,</span>
      <span class='label'>name:</span> <span class='id identifier rubyid_first_name'>first_name</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_authorization'>authorization</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='kw'>if</span> <span class='id identifier rubyid_authorization'>authorization</span><span class='rparen'>)</span><span class='comma'>,</span>
      <span class='label'>link:</span> <span class='lparen'>(</span><span class='id identifier rubyid_authorization'>authorization</span><span class='period'>.</span><span class='id identifier rubyid_link'>link</span> <span class='kw'>if</span> <span class='id identifier rubyid_authorization'>authorization</span><span class='rparen'>)</span><span class='comma'>,</span>
      <span class='label'>image:</span> <span class='lparen'>(</span><span class='id identifier rubyid_authorization'>authorization</span><span class='period'>.</span><span class='id identifier rubyid_image_url'>image_url</span> <span class='kw'>if</span> <span class='id identifier rubyid_authorization'>authorization</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_gravatar_url'>gravatar_url</span>
    <span class='rbrace'>}</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the name if it is present or else get the email
</span>  <span class='comment'># @return [String] the name or email of the user
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_name_or_email'>name_or_email</span>
     <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_full_name'>full_name</span> <span class='op'>||</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_email'>email</span>
  <span class='kw'>end</span>

  <span class='comment'># Get the user's full name (the concatenation of his first and last names)
</span>  <span class='comment'># @return [String] the user's full name
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_full_name'>full_name</span>
    <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_first_name'>first_name</span><span class='rbrace'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_last_name'>last_name</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span>
    <span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='kw'>nil</span> <span class='op'>:</span> <span class='id identifier rubyid_name'>name</span>
  <span class='kw'>end</span>

  <span class='comment'># Alias for name_or_email
</span>  <span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_name_or_email'>name_or_email</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_protected'>protected</span>

  <span class='kw'>def</span> <span class='id identifier rubyid_check_no_of_users'>check_no_of_users</span>
    <span class='kw'>if</span> <span class='const'>Citygate</span><span class='op'>::</span><span class='const'>Engine</span><span class='period'>.</span><span class='id identifier rubyid_no_of_users'>no_of_users</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>&amp;&amp;</span> <span class='const'>Citygate</span><span class='op'>::</span><span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>&gt;=</span> <span class='const'>Citygate</span><span class='op'>::</span><span class='const'>Engine</span><span class='period'>.</span><span class='id identifier rubyid_no_of_users'>no_of_users</span>
      <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='symbol'>:base</span><span class='comma'>,</span><span class='const'>I18n</span><span class='op'>::</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>users.errors.too_many</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
      <span class='kw'>return</span> <span class='kw'>false</span>
    <span class='kw'>else</span>
      <span class='kw'>return</span> <span class='kw'>true</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="as_json-instance_method">
  
    - (<tt>Hash</tt>) <strong>as_json</strong>(options = {}) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>
Get the json object for an user. Used by to_json.
</p>


  </div>
</div>
<div class="tags">
  
  <div class="examples">
    <p class="tag_title">Examples:</p>
    
      
      <pre class="example code">{
  &quot;email&quot;: &quot;user@example.com&quot;,
  &quot;name&quot;: &quot;First User&quot;,
  &quot;link&quot;: null,
  &quot;image&quot;: &quot;https://secure.gravatar.com/avatar/b58996c504c5638798eb6b511e6f49af.png/rating=g&quot;
}</pre>
    
  </div>

<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Hash</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
the json object in the form of an hash
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


34
35
36
37
38
39
40
41
42</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/citygate/user.rb', line 34</span>

<span class='kw'>def</span> <span class='id identifier rubyid_as_json'>as_json</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_authorization'>authorization</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_authorizations'>authorizations</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
  <span class='lbrace'>{</span>
    <span class='label'>email:</span> <span class='id identifier rubyid_email'>email</span><span class='comma'>,</span>
    <span class='label'>name:</span> <span class='id identifier rubyid_first_name'>first_name</span> <span class='op'>||</span> <span class='lparen'>(</span><span class='id identifier rubyid_authorization'>authorization</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='kw'>if</span> <span class='id identifier rubyid_authorization'>authorization</span><span class='rparen'>)</span><span class='comma'>,</span>
    <span class='label'>link:</span> <span class='lparen'>(</span><span class='id identifier rubyid_authorization'>authorization</span><span class='period'>.</span><span class='id identifier rubyid_link'>link</span> <span class='kw'>if</span> <span class='id identifier rubyid_authorization'>authorization</span><span class='rparen'>)</span><span class='comma'>,</span>
    <span class='label'>image:</span> <span class='lparen'>(</span><span class='id identifier rubyid_authorization'>authorization</span><span class='period'>.</span><span class='id identifier rubyid_image_url'>image_url</span> <span class='kw'>if</span> <span class='id identifier rubyid_authorization'>authorization</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_gravatar_url'>gravatar_url</span>
  <span class='rbrace'>}</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="check_no_of_users-instance_method">
  
    - (<tt>Object</tt>) <strong>check_no_of_users</strong>  <span class="extras">(protected)</span>
  

  

  
</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


64
65
66
67
68
69
70
71</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/citygate/user.rb', line 64</span>

<span class='kw'>def</span> <span class='id identifier rubyid_check_no_of_users'>check_no_of_users</span>
  <span class='kw'>if</span> <span class='const'>Citygate</span><span class='op'>::</span><span class='const'>Engine</span><span class='period'>.</span><span class='id identifier rubyid_no_of_users'>no_of_users</span> <span class='op'>&gt;</span> <span class='int'>0</span> <span class='op'>&amp;&amp;</span> <span class='const'>Citygate</span><span class='op'>::</span><span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span> <span class='op'>&gt;=</span> <span class='const'>Citygate</span><span class='op'>::</span><span class='const'>Engine</span><span class='period'>.</span><span class='id identifier rubyid_no_of_users'>no_of_users</span>
    <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='symbol'>:base</span><span class='comma'>,</span><span class='const'>I18n</span><span class='op'>::</span><span class='id identifier rubyid_t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>users.errors.too_many</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
    <span class='kw'>return</span> <span class='kw'>false</span>
  <span class='kw'>else</span>
    <span class='kw'>return</span> <span class='kw'>true</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="full_name-instance_method">
  
    - (<tt>String</tt>) <strong>full_name</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>
Get the user&#8217;s full name (the concatenation of his first and last
names)
</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
the user&#8217;s full name
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


52
53
54
55</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/citygate/user.rb', line 52</span>

<span class='kw'>def</span> <span class='id identifier rubyid_full_name'>full_name</span>
  <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_first_name'>first_name</span><span class='rbrace'>}</span><span class='tstring_content'> </span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_last_name'>last_name</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='period'>.</span><span class='id identifier rubyid_strip'>strip</span>
  <span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='kw'>nil</span> <span class='op'>:</span> <span class='id identifier rubyid_name'>name</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="name_or_email-instance_method">
  
    - (<tt>String</tt>) <strong>name_or_email</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>
Get the name if it is present or else get the email
</p>


  </div>
</div>
<div class="tags">
  
<p class="tag_title">Returns:</p>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
the name or email of the user
</p>
</div>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


46
47
48</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/citygate/user.rb', line 46</span>

<span class='kw'>def</span> <span class='id identifier rubyid_name_or_email'>name_or_email</span>
   <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_full_name'>full_name</span> <span class='op'>||</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_email'>email</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="to_s-instance_method">
  
    - (<tt>Object</tt>) <strong>to_s</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>
Alias for name_or_email
</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


58
59
60</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'app/models/citygate/user.rb', line 58</span>

<span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span>
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_name_or_email'>name_or_email</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

    <div id="footer">
  Generated on Thu Sep 20 15:56:37 2012 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.8.2.1 (ruby-1.9.2).
</div>

  </body>
</html>